<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>5G登录查询</title>
    <link rel="icon" href="assets/favicon.ico">
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="container">
        <div class="logo">
            <img src="assets/5g-logo.svg" alt="5G Logo">
        </div>
        <div class="query-card">
            <h1>登录查询</h1>
            <div class="input-group">
                <input type="text" id="queryInput" placeholder="" value="">
                <button class="scan-btn">
                    <img src="assets/shaomiao.png" alt="扫描">
                </button>
            </div>
            <button class="query-btn" onclick="handleQuery()">查询</button>
        </div>
    </div>

    <script>
        async function handleQuery() {
            const queryInput = document.getElementById('queryInput');
            const inputValue = queryInput.value.trim();
            
            if (!inputValue) {
                alert('请输入查询号码');
                return;
            }

            try {
                // 发送AJAX请求
                const response = await fetch(`http://xj.iot998.cn/app/realname/phoneQuery?phone=${inputValue}`);
                const data = await response.json();

                if (data.status === true) {
                    // 登录成功，跳转到新页面
                    window.location.href = `http://xj.iot998.cn/wap/index.html#/home?card=${inputValue}`;
                } else {
                    // 登录失败，显示错误信息
                    alert(data.msg || '查询失败，请重试');
                }
            } catch (error) {
                console.error('请求出错：', error);
                alert('网络错误，请稍后重试');
            }
        }

        // 添加回车键触发查询
        document.getElementById('queryInput').addEventListener('keypress', function(event) {
            if (event.key === 'Enter') {
                handleQuery();
            }
        });
    </script>
</body>
</html> 